<?php

namespace app\popo\dto;

use app\popo\vo\Required;
use Webman\Http\Request;

class ShoppingCartDTO extends BaseDto
{
    private ?int $dishId = null;
    private ?int $setmealId = null;
    private ?string $dishFlavor = null;
    
    #[Required]
    private int $number;
    
    public function __construct(Request $request)
    {
        $this->dishId = $request->input("dishId") ? (int)$request->input("dishId") : null;
        $this->setmealId = $request->input("setmealId") ? (int)$request->input("setmealId") : null;
        $this->dishFlavor = $request->input("dishFlavor");
        $this->number = (int)$request->input("number", 1);
        $this->validateRequired();
    }

    public function getDishId(): ?int
    {
        return $this->dishId;
    }

    public function getSetmealId(): ?int
    {
        return $this->setmealId;
    }

    public function getDishFlavor(): ?string
    {
        return $this->dishFlavor;
    }

    public function getNumber(): int
    {
        return $this->number;
    }

    public function toArray(): array
    {
        return [
            'dishId' => $this->dishId,
            'setmealId' => $this->setmealId,
            'dishFlavor' => $this->dishFlavor,
            'number' => $this->number
        ];
    }
}